﻿@using BonjourQuotation.UI.Models.PartialModel
@using MvcCheckBoxList
@model OperationVendorConfirmationViewModel
@{
    Layout = null;
}
<script type="text/javascript">
    var VConfModel;
    debugger;
    LoadVConfGrid();

    function LoadVConfGrid() {
        VConfModel = $(@Html.Raw(Json.Encode(Model))).JSModel();
        var VConfcolumnHeaders = [];
        var VConfcolumns = [];
        var VConfcolWidth = [];
        var VConfMealcolumnHeaders = [];
        var VConfMealcolumns = [];
        var VConfMealcolWidth = [];
        var VConfRoomcolumnHeaders = [];
        var VConfRoomcolumns = [];
        var VConfRoomcolWidth = [];
        var VConfServicedrop = [];

        // Day
        VConfRoomcolumnHeaders.push($("#VCnfRoomDayDiv").html());
        VConfRoomcolumns.push({ data: "ConfRoomDay", type: "numeric" });
        VConfRoomcolWidth.push(50);
        // Single Price
        VConfRoomcolumnHeaders.push($("#VCnfSinglePriceDiv").html());
        VConfRoomcolumns.push({ data: "ConfRoomSinglePrice", type: "numeric", format: '$0,0.00' });
        VConfRoomcolWidth.push(75);
        // Single Qty
        VConfRoomcolumnHeaders.push($("#VCnfSingleQtyDiv").html());
        VConfRoomcolumns.push({ data: "ConfRoomSingleQty", type: "numeric", readOnly: true });
        VConfRoomcolWidth.push(60);
        // Double Price
        VConfRoomcolumnHeaders.push($("#VCnfDoublePriceDiv").html());
        VConfRoomcolumns.push({ data: "ConfRoomDoublePrice", type: "numeric", format: '$0,0.00' });
        VConfRoomcolWidth.push(75);
        // Double Qty
        VConfRoomcolumnHeaders.push($("#VCnfDoubleQtyDiv").html());
        VConfRoomcolumns.push({ data: "ConfRoomDoubleQty", type: "numeric", readOnly: true });
        VConfRoomcolWidth.push(60);
        // Twin Price
        VConfRoomcolumnHeaders.push($("#VCnfTwinPriceDiv").html());
        VConfRoomcolumns.push({ data: "ConfRoomTwinPrice", type: "numeric", format: '$0,0.00' });
        VConfRoomcolWidth.push(75);
        // Twin Qty
        VConfRoomcolumnHeaders.push($("#VCnfTwinQtyDiv").html());
        VConfRoomcolumns.push({ data: "ConfRoomTwinQty", type: "numeric", readOnly: true });
        VConfRoomcolWidth.push(60);
        // Triple Price
        VConfRoomcolumnHeaders.push($("#VCnfTriplePriceDiv").html());
        VConfRoomcolumns.push({ data: "ConfRoomTriplePrice", type: "numeric", format: '$0,0.00' });
        VConfRoomcolWidth.push(75);
        // Triple Qty
        VConfRoomcolumnHeaders.push($("#VCnfTripleQtyDiv").html());
        VConfRoomcolumns.push({ data: "ConfRoomTripleQty", type: "numeric", readOnly: true });
        VConfRoomcolWidth.push(60);
        // Quad Price
        VConfRoomcolumnHeaders.push($("#VCnfQuadPriceDiv").html());
        VConfRoomcolumns.push({ data: "ConfRoomQuadPrice", type: "numeric", format: '$0,0.00' });
        VConfRoomcolWidth.push(75);
        // Quad Qty
        VConfRoomcolumnHeaders.push($("#VCnfQuadQtyDiv").html());
        VConfRoomcolumns.push({ data: "ConfRoomQuadQty", type: "numeric", readOnly: true });
        VConfRoomcolWidth.push(60);
        // Driver Price
        VConfRoomcolumnHeaders.push($("#VCnfDriverPriceDiv").html());
        VConfRoomcolumns.push({ data: "ConfRoomDriverPrice", type: "numeric", format: '$0,0.00' });
        VConfRoomcolWidth.push(75);
        // Driver Qty
        VConfRoomcolumnHeaders.push($("#VCnfDriverQtyDiv").html());
        VConfRoomcolumns.push({ data: "ConfRoomDriverQty", type: "numeric", readOnly: true });
        VConfRoomcolWidth.push(60);
        // Guide Price
        VConfRoomcolumnHeaders.push($("#VCnfGuidePriceDiv").html());
        VConfRoomcolumns.push({ data: "ConfRoomGuidePrice", type: "numeric", format: '$0,0.00' });
        VConfRoomcolWidth.push(75);
        // Guide Qty
        VConfRoomcolumnHeaders.push($("#VCnfGuideQtyDiv").html());
        VConfRoomcolumns.push({ data: "ConfRoomGuideQty", type: "numeric", readOnly: true });
        VConfRoomcolWidth.push(60);
        // Baggage Price
        VConfRoomcolumnHeaders.push($("#VCnfBaggagePriceDiv").html());
        VConfRoomcolumns.push({ data: "ConfRoomBaggagePrice", type: "numeric", format: '$0,0.00' });
        VConfRoomcolWidth.push(75);
        // Baggage Qty
        VConfRoomcolumnHeaders.push($("#VCnfBaggageQtyDiv").html());
        VConfRoomcolumns.push({ data: "ConfRoomBaggageQty", type: "numeric" });
        VConfRoomcolWidth.push(70);

        // Meal Grid
        // Day
        VConfMealcolumnHeaders.push($("#VCnfRoomDayDiv").html());
        VConfMealcolumns.push({ data: "ConfMealDay", type: "numeric" });
        VConfMealcolWidth.push(50);
        // ABF Price
        VConfMealcolumnHeaders.push($("#VCnfABFPriceDiv").html());
        VConfMealcolumns.push({ data: "ConfMealABFPrice", type: "numeric", format: '$0,0.00' });
        VConfMealcolWidth.push(75);
        // ABF Qty
        VConfMealcolumnHeaders.push($("#VCnfABFQtyDiv").html());
        VConfMealcolumns.push({ data: "ConfMealABFQty", type: "numeric" });
        VConfMealcolWidth.push(60);
        // ABF Check
        VConfMealcolumnHeaders.push("Sel");
        VConfMealcolumns.push({ data: "ConfMealABFCheck", type: "checkbox" });
        VConfMealcolWidth.push(23);
        // Cont Price
        VConfMealcolumnHeaders.push($("#VCnfCBFPriceDiv").html());
        VConfMealcolumns.push({ data: "ConfMealCBFPrice", type: "numeric", format: '$0,0.00' });
        VConfMealcolWidth.push(75);
        // Cont Qty
        VConfMealcolumnHeaders.push($("#VCnfCBFQtyDiv").html());
        VConfMealcolumns.push({ data: "ConfMealCBFQty", type: "numeric" });
        VConfMealcolWidth.push(60);
        // Cont Check
        VConfMealcolumnHeaders.push("Sel");
        VConfMealcolumns.push({ data: "ConfMealCBFCheck", type: "checkbox" });
        VConfMealcolWidth.push(23);
        // Lunch Price
        VConfMealcolumnHeaders.push($("#VCnfLunchPriceDiv").html());
        VConfMealcolumns.push({ data: "ConfMealLunchPrice", type: "numeric", format: '$0,0.00' });
        VConfMealcolWidth.push(75);
        // Lunch Qty
        VConfMealcolumnHeaders.push($("#VCnfLunchQtyDiv").html());
        VConfMealcolumns.push({ data: "ConfMealLunchQty", type: "numeric" });
        VConfMealcolWidth.push(60);
        // Lunch Check
        VConfMealcolumnHeaders.push("Sel");
        VConfMealcolumns.push({ data: "ConfMealLunchCheck", type: "checkbox" });
        VConfMealcolWidth.push(23);
        // Dinner Price
        VConfMealcolumnHeaders.push($("#VCnfDinnerPriceDiv").html());
        VConfMealcolumns.push({ data: "ConfMealDinnerPrice", type: "numeric", format: '$0,0.00' });
        VConfMealcolWidth.push(75);
        // Dinner Qty
        VConfMealcolumnHeaders.push($("#VCnfDinnerQtyDiv").html());
        VConfMealcolumns.push({ data: "ConfMealDinnerQty", type: "numeric" });
        VConfMealcolWidth.push(60);
        // Dinner Check
        VConfMealcolumnHeaders.push("Sel");
        VConfMealcolumns.push({ data: "ConfMealDinnerCheck", type: "checkbox" });
        VConfMealcolWidth.push(23);
        // Date
        VConfMealcolumnHeaders.push($("#VCnfDateDiv").html());
        VConfMealcolumns.push({ data: "StartDate", type: "date", dateFormat: 'D, dd/M/yy', readOnly:true });
        VConfMealcolWidth.push(140);

        // init Service
        $(VConfModel[0].ConfService).each(function (index, elem) {
            VConfServicedrop.push(elem.Text);
        });
        // Line No
        VConfcolumnHeaders.push("Ln");
        VConfcolumns.push({ data: "ConfLineNo", type: "numeric" });
        VConfcolWidth.push(50);
        // Service Type
        VConfcolumnHeaders.push("Service");
        VConfcolumns.push({ data: "ConfSelService", type: "dropdown", source: VConfServicedrop });
        VConfcolWidth.push(180);
        // Price
        VConfcolumnHeaders.push("Price");
        VConfcolumns.push({ data: "ConfPrice", type: "numeric", format: '$0,0.00' });
        VConfcolWidth.push(90);
        //// Manual
        //VConfcolumnHeaders.push("M");
        //VConfcolumns.push({ data: "ConfManual", type: "checkbox" });
        //VConfcolWidth.push(40);
        // Days
        VConfcolumnHeaders.push("#");
        VConfcolumns.push({ data: "ConfXQty", type: "numeric" });
        VConfcolWidth.push(60);
        // Qty
        VConfcolumnHeaders.push("Qty");
        VConfcolumns.push({ data: "ConfQty", type: "numeric" });
        VConfcolWidth.push(60);
        // From
        VConfcolumnHeaders.push("From");
        VConfcolumns.push({ data: "ConfStartDate", type: "date", dateFormat: 'D, dd/M/yy' });
        VConfcolWidth.push(140);
        // To
        VConfcolumnHeaders.push("To");
        VConfcolumns.push({ data: "ConfEndDate", type: "date", dateFormat: 'D, dd/M/yy' });
        VConfcolWidth.push(140);
        // Desc
        VConfcolumnHeaders.push("Description");
        VConfcolumns.push({ data: "ConfDescription", type: "text" });
        VConfcolWidth.push(452);

        RedColorRenderer = function (instance, td, row, col, prop, value, cellProperties) {
            Handsontable.renderers.NumericRenderer.apply(this, arguments);
            td.style.color = 'red';
        };

        VCRedColorRendererForNegative = function (instance, td, row, col, prop, value, cellProperties) {
            Handsontable.renderers.NumericRenderer.apply(this, arguments);
            td.style.color = 'red';
        };

        var VConfRoomdata = VConfModel[0].RoomRows;
        $("#OperVConfirmRoomGrid").show();
        $('#OperVConfirmRoomGrid').handsontable({
            data: VConfRoomdata,
            minSpareRows: 0,
            colHeaders: VConfRoomcolumnHeaders,
            colWidths: VConfRoomcolWidth,
            contextMenu: false,
            manualColumnResize: true,
            manualRowResize: true,
            columns: VConfRoomcolumns,
            afterChange: function (data, source) {
                if (data != null) {
                    CheckOperVendConfDataChanges();
                }
            },
            cells: function (row, col, prop) {
                var Cellinstance = this;
                if (prop == "ConfRoomDay") {
                    Cellinstance.renderer = RedColorRenderer;
                }
                else if (Cellinstance.renderer == Handsontable.renderers.NumericRenderer && Cellinstance.instance.getDataAtCell(row, col) < 0) {
                    Cellinstance.renderer = VCRedColorRendererForNegative;
                }
            }
        });

        var VConfMealdata = VConfModel[0].MealRows;
        $("#OperVConfirmMealGrid").show();
        $('#OperVConfirmMealGrid').handsontable({
            data: VConfMealdata,
            minSpareRows: 0,
            colHeaders: VConfMealcolumnHeaders,
            colWidths: VConfMealcolWidth,
            contextMenu: false,
            manualColumnResize: true,
            manualRowResize: true,
            columns: VConfMealcolumns,
            afterChange: function (data, source) {
                if (data != null) {
                    CheckOperVendConfDataChanges();
                    var instance = this;
                    if (data[0][1] == "ConfMealABFCheck") {
                        if (data[0][3] == true && instance.getData()[data[0][0]].ConfMealCBFCheck == true) {
                            jAlert("Can't be 2 types of Breakfast.", "Warning!");
                            instance.getData()[data[0][0]].ConfMealABFCheck = false;
                            instance.render();
                        }
                    }
                    if (data[0][1] == "ConfMealCBFCheck") {
                        if (data[0][3] == true && instance.getData()[data[0][0]].ConfMealABFCheck == true) {
                            jAlert("Can't be 2 types of Breakfast.", "Warning!");
                            instance.getData()[data[0][0]].ConfMealCBFCheck = false;
                            instance.render();
                        }
                    }
                }
            },
            cells: function (row, col, prop) {
                var Cellinstance = this;
                if (prop == "ConfMealDay") {
                    Cellinstance.renderer = RedColorRenderer;
                }
                else if (Cellinstance.renderer == Handsontable.renderers.NumericRenderer && Cellinstance.instance.getDataAtCell(row, col) < 0) {
                    Cellinstance.renderer = VCRedColorRendererForNegative;
                }
            }
        });
      
        var VConfdata = VConfModel[0].Rows;
        $("#OperVConfirmGrid").show();
        $('#OperVConfirmGrid').handsontable({
            data: VConfdata,
            minSpareRows: 1,
            colHeaders: VConfcolumnHeaders,
            colWidths: VConfcolWidth,
            contextMenu: false,
            manualColumnResize: true,
            manualRowResize: true,
            columns: VConfcolumns,
            afterChange: function (data, source) {
                if (data != null) {
                    debugger
                    CheckOperVendConfDataChanges();
                    var instance = this;
                    if (data[0][1] == "ConfStartDate") {
                        if (data[0][3] != null) {
                            if (instance.getData()[data[0][0]].ConfEndDate != null) {
                                var FromNoformated = Date.parse(data[0][3]);
                                var NewFromDate = new Date(FromNoformated);
                                var ToNoformated = Date.parse(instance.getData()[data[0][0]].ConfEndDate);
                                var NewToDate = new Date(ToNoformated);
                                if (DaysBetween(NewToDate, NewFromDate) < 0) {
                                    instance.getData()[data[0][0]].ConfStartDate = data[0][2];
                                    jAlert("From date can not be greater then to date", "Error!");
                                }
                                else {
                                    instance.getData()[data[0][0]].ConfXQty = DaysBetween(NewToDate, NewFromDate);
                                }
                                instance.render();
                            }
                        }
                    }
                    if (data[0][1] == "ConfEndDate") {
                        if (data[0][3] != null) {
                            if (instance.getData()[data[0][0]].ConfStartDate != null) {
                                var ToNoformated = Date.parse(data[0][3]);
                                var NewToDate = new Date(ToNoformated);
                                var FromNoformated = Date.parse(instance.getData()[data[0][0]].ConfStartDate);
                                var NewFromDate = new Date(FromNoformated);
                                if (DaysBetween(NewToDate, NewFromDate) < 0) {
                                    instance.getData()[data[0][0]].ConfEndDate = data[0][2];
                                    jAlert("To date can not be less then from date", "Error!");
                                }
                                else {
                                    instance.getData()[data[0][0]].ConfXQty = DaysBetween(NewToDate, NewFromDate);
                                }
                                instance.render();
                            }
                        }
                    }
                }
            },
            cells: function (row, col, prop) {
                var Cellinstance = this;
                if (Cellinstance.renderer == Handsontable.renderers.NumericRenderer && Cellinstance.instance.getDataAtCell(row, col) < 0) {
                    Cellinstance.renderer = VCRedColorRendererForNegative;
                }
            }
            // dataSchema: {ConfManual: false},
        });
    }
    function DaysBetween(date1, date2) {

        // The number of milliseconds in one day
        var ONE_DAY = 1000 * 60 * 60 * 24

        // Convert both dates to milliseconds
        var date1_ms = date1.getTime()
        var date2_ms = date2.getTime()

        // Calculate the difference in milliseconds
        var difference_ms = date1_ms - date2_ms;

        // Convert back to days and return
        return Math.round(difference_ms / ONE_DAY)

    }
    // Save VConfirm Data
    function VConfirmGridSave() {
        debugger;
        var IsValidService = true;
        var IsValidPrice = true;
        var IsValidQty = true;
        var IsValidFrom = true;
        var IsValidTo = true;
        var Rows = $('#OperVConfirmGrid').data('handsontable').getData();
        var RoomRows = $('#OperVConfirmRoomGrid').data('handsontable').getData();
        var MealRows = $('#OperVConfirmMealGrid').data('handsontable').getData();
        if (RoomRows.length > 0) {
            if (Rows.length > 1) {
                $(Rows).each(function (index, elem) {
                    if (index < Rows.length - 1) {
                        // all validations here
                        if (elem.ConfSelService == undefined || (elem.ConfSelService != undefined && elem.ConfSelService.length == 0))
                            IsValidService = false;
                        if (elem.ConfPrice == undefined || (elem.ConfPrice != undefined && elem.ConfPrice.length == 0))
                            IsValidPrice = false;
                        if (elem.ConfQty == undefined || (elem.ConfQty != undefined && elem.ConfQty.length == 0))
                            IsValidQty = false;
                        if (elem.ConfStartDate == undefined || (elem.ConfStartDate != undefined && elem.ConfStartDate.length == 0))
                            IsValidFrom = false;
                        if (elem.ConfEndDate == undefined || (elem.ConfEndDate != undefined && elem.ConfEndDate.length == 0))
                            IsValidTo = false;
                    }
                });
            }
            if (IsValidService == false) {
                jAlert("Service can't be empty.", "Error!");
                return;
            }
            if (IsValidPrice == false) {
                jAlert("Price can't be empty.", "Error!");
                return;
            }
            if (IsValidQty == false) {
                jAlert("Qty can't be empty.", "Error!");
                return;
            }
            if (IsValidFrom == false) {
                jAlert("From date can't be empty.", "Error!");
                return;
            }
            if (IsValidTo == false) {
                jAlert("To date can't be empty.", "Error!");
                return;
            }
            var RowsVcnfValidate = $('#OperVConfirmGrid').find('.htInvalid');
            if (RowsVcnfValidate.length > 0) {
                jAlert("You have invalid data", "Error!");
                return;
            }
            var RowsValidate = $('#OperVConfirmRoomGrid').find('.htInvalid');
            if (RowsValidate.length == 0) {
                $(Rows).each(function (index, elem) {
                    if (elem.ConfSelService != null) {
                        $(VConfModel[0].ConfService).each(function (index1, elem1) {
                            if (elem1.Text == elem.ConfSelService) {
                                elem.ConfSelServiceID = elem1.Value;
                            }
                        });
                    }
                });

                var OperationVendorConfirmationViewModel = {
                    Rows: Rows,
                    RoomRows: RoomRows,
                    MealRows: MealRows,
                    ConfArrivalDate: $("#ConfArrivalDate").val(),
                    ConfArrivalTime: $("#ConfArrivalTime").val(),
                    ConfDepartureDate: $("#ConfDepartureDate").val(),
                    ConfDepartureTime: $("#ConfDepartureTime").val(),
                    ConfSelectedStatus: $("#ConfSelectedStatus").val(),
                    ConfGroupID: $("#ConfGroupID").val(),
                    ConfVendorID: $("#ConfVendorID").val(),
                    ConfConfirmedBy: $("#ConfConfirmedBy").val(),
                    ConfConfirmDate: $("#ConfConfirmDate").val(),
                    ConfNote: $("#ConfNote").val(),
                    ConfIssueDate: $("#ConfIssueDate").val(),
                    ConfRooms: $("#ConfRooms").val(),
                    ConfPax: $("#ConfPax").val(),
                    ConfLuggage: $("#ConfLuggage").val(),
                    ConfTax: $("#ConfTax").val(),
                    ConfOccTax: $("#ConfOccTax").val(),
                };

                var DTO = JSON.stringify(OperationVendorConfirmationViewModel);

                $.ajax({
                    url: urls["OperationVConfirmGridSave"],
                    type: 'POST',
                    contentType: 'application/json; charset=utf-8',
                    data: DTO,
                    success: function (data) {
                        $("#tabConfirmation").html(data);
                    },
                    error: function (xhr) {
                        //   alert('Error: ' + xhr.statusText);
                    },
                    complete: function () {
                        LoadHotelGridByGroupCode($("#ConfGroupCode").val());
                        UpdateProvide();
                    }
                });
            }
            else {
                jAlert("You have invalid data", "Error!");
            }
        }
        else {
            jAlert("You have not any data for save", "Error!");
        }
    }
    // Vendor Conf details changed
    $(document).on('change', '.VendorConfDetData', function () {
        if (!$("#operVendConfsavebtn").hasClass("GridDataChanged"))
            $("#operVendConfsavebtn").addClass("GridDataChanged");
    });
    function CheckOperVendConfDataChanges() {
        if (!$("#operVendConfsavebtn").hasClass("GridDataChanged"))
            $("#operVendConfsavebtn").addClass("GridDataChanged");
    }
    function ReportVConfirmBreakDown() {
        var IsInValidForReportRoomSingle = false;
        var IsInValidForReportRoomDouble = false;
        var IsInValidForReportRoomTwin = false;
        var IsInValidForReportRoomTriple = false;
        var IsInValidForReportRoomQuad = false;
        var IsInValidForReportRoomDriver = false;
        var IsInValidForReportRoomGuide = false;
        VConfModelForReport = $(@Html.Raw(Json.Encode(Model))).JSModel();
        $(VConfModelForReport[0].RoomRows).each(function (index, elem) {
                // all validations here
            if (elem.ConfRoomSingleQty > 0) {
                if (elem.ConfRoomSinglePrice <= 0) {
                    IsInValidForReportRoomSingle = true;
                    return;
                }
            }
            if (elem.ConfRoomDoubleQty > 0) {
                if (elem.ConfRoomDoublePrice <= 0) {
                    IsInValidForReportRoomDouble = true;
                    return;
                }
            }
            if (elem.ConfRoomTwinQty > 0) {
                if (elem.ConfRoomTwinPrice <= 0) {
                    IsInValidForReportRoomTwin = true;
                    return;
                }
            }
            if (elem.ConfRoomTripleQty > 0) {
                if (elem.ConfRoomTriplePrice <= 0) {
                    IsInValidForReportRoomTriple = true;
                    return;
                }
            }
            if (elem.ConfRoomQuadQty > 0) {
                if (elem.ConfRoomQuadPrice <= 0) {
                    IsInValidForReportRoomQuad = true;
                    return;
                }
            }
            if (elem.ConfRoomDriverQty > 0) {
                if (elem.ConfRoomDriverPrice <= 0) {
                    IsInValidForReportRoomDriver = true;
                    return;
                }
            }
            if (elem.ConfRoomGuideQty > 0) {
                if (elem.ConfRoomGuidePrice <= 0) {
                    IsInValidForReportRoomGuide = true;
                    return;
                }
            }
        });
        if (IsInValidForReportRoomSingle) {
            jAlert("Single price can not be 0", "Error!");
            return;
        }
        if (IsInValidForReportRoomDouble) {
            jAlert("Double price can not be 0", "Error!");
            return;
        }
        if (IsInValidForReportRoomTwin) {
            jAlert("Twin price can not be 0", "Error!");
            return;
        }
        if (IsInValidForReportRoomTriple) {
            jAlert("Triple price can not be 0", "Error!");
            return;
        }
        if (IsInValidForReportRoomQuad) {
            jAlert("Quad price can not be 0", "Error!");
            return;
        }
        if (IsInValidForReportRoomDriver) {
            jAlert("Driver price can not be 0", "Error!");
            return;
        }
        if (IsInValidForReportRoomGuide) {
            jAlert("Guide price can not be 0", "Error!");
            return;
        }
        window.open("../Report/VConfirmBreakDown?VendorID=" + VConfModel[0].ConfVendorID + "&GroupID=" + VConfModel[0].ConfGroupID + "&ArrivalDate=" + VConfModel[0].ConfArrivalDate);
    }
    function UpdateProvide()
    {
        $.ajax({
            url: urls["OperationVConfirmUpdateProvide"],
            type: 'POST',
            data: { 'GroupID': $("#ConfGroupID").val(), 'VendorID': $("#ConfVendorID").val(), 'ArrivalDate': $("#ConfArrivalDate").val() },
            success: function (data) {
                if (data.errorCode == 0)
                    jAlert("Provide succesfully updated.", "Info!");
                else
                    jAlert(data, "Error!");
            },
            error: function (xhr) {
                //   alert('Error: ' + xhr.statusText);
            },
            complete: function () {
                OperGroupVendorConfRoomLoad($("#ConfGroupID").val(), $("#ConfVendorID").val());
            }
        });
    }
</script>

@using (Ajax.BeginForm("SaveOperationVendorConfirmationData", "Operation", new AjaxOptions() { HttpMethod = "Post", UpdateTargetId = "tabConfirmation", InsertionMode = InsertionMode.Replace }, new { enctype = "multipart/form-data", id = "OperVendorConfirmationForm" }))
{
    <div class="OperationTabsTitleDiv">
        @Html.LabelForModel(Model.ConfVendorName, new { @class = "OperationTabsTitle" })
    </div>
    @Html.HiddenFor(model=>model.ConfGroupID)
    @Html.HiddenFor(model=>model.ConfGroupCode)
    @Html.HiddenFor(model=>model.ConfVendorID)
    @Html.HiddenFor(model => model.VendorType)
    <div style="height: 185px; width: 1172px; background-color: rgba(128, 128, 128, 0.8);">
        <div class="pull-right" style="margin-left:25px; margin-bottom:15px;">

            <div class="row form-row">
                <div class="ElementsPaddingRight30 col-lg-2" style="width:25% !important;">
                    <div class="input-group">
                        <span class="input-group-addon inpputgrtext table_inputs_SmallPadding2 inpputgrback">@Html.LabelFor(model => model.ConfArrivalDate)</span>
                        @Html.TextBoxFor(model => model.ConfArrivalDate, new { @class = "table_inputs_SmallPadding2 inpputgr form-control", @readonly = true })
                    </div>
                </div>
                <div class="ElementsPaddingRight30 col-lg-1">
                    @Html.TextBoxFor(model => model.ConfArrivalTime, new { @class = "table_inputs_SmallPadding2 inpputgr form-control VendConfCalendarTime VendorConfDetData" })
                </div>
                <div class="ElementsPaddingRight30  col-lg-2" style="width:25% !important;">
                    <div class="input-group">
                        <span class="input-group-addon inpputgrtext table_inputs_SmallPadding2 inpputgrback">@Html.LabelFor(model => model.ConfDepartureDate)</span>
                        @Html.TextBoxFor(model => model.ConfDepartureDate, new { @class = "table_inputs_SmallPadding2 inpputgr form-control VendConfCalendar VendorConfDetData" })
                    </div>
                </div>
                <div class="ElementsPaddingRight30 col-lg-1">
                    @Html.TextBoxFor(model => model.ConfDepartureTime, new { @class = "table_inputs_SmallPadding2 inpputgr form-control VendConfCalendarTime VendorConfDetData" })
                </div>
                @*<div class="ElementsPaddingRight30 col-lg-1" style="width:12% !important;">
                    <div class="input-group">
                        <span class="input-group-addon" style="margin-left:5px;">@Html.LabelFor(model => model.ConfVoucher)</span>
                        @Html.CheckBoxFor(model => model.ConfVoucher)
                    </div>
                     </div>*@
                <div class="ElementsPaddingRight30 col-lg-3" style="width:32.4% !important;">
                    <div class="input-group">
                        <span class="input-group-addon inpputgrtext table_inputs_SmallPadding2 inpputgrback">@Html.LabelFor(model => model.ConfStatus)</span>
                        @Html.DropDownListFor(x => x.ConfSelectedStatus, new SelectList(Model.ConfStatus, "Value", "Text"), new { @class = "table_inputs_SmallPadding2 inpputgr form-control VendorConfDetData" })
                    </div>
                </div>
            </div>
            <div class="row form-row">
                <div class="ElementsPaddingRight30 col-lg-3" style="width:19% !important;">
                    <div class="input-group">
                        <span class="input-group-addon inpputgrtext table_inputs_SmallPadding2 inpputgrback">@Html.LabelFor(model => model.ConfIssueDate)</span>
                        @Html.TextBoxFor(model => model.ConfIssueDate, new { @class = "table_inputs_SmallPadding2 inpputgr form-control VendConfCalendar VendorConfDetData" })
                    </div>
                </div>
                <div class="ElementsPaddingRight30 col-lg-3">
                    <div class="input-group">
                        <span class="input-group-addon inpputgrtext table_inputs_SmallPadding2 inpputgrback">@Html.LabelFor(model => model.ConfConfirmedBy)</span>
                        @Html.TextBoxFor(model => model.ConfConfirmedBy, new { @class = "table_inputs_SmallPadding2 inpputgr form-control VendorConfDetData" })
                    </div>
                </div>
                <div class="ElementsPaddingRight30 col-lg-2">
                    <div class="input-group">
                        <span class="input-group-addon inpputgrtext table_inputs_SmallPadding2 inpputgrback">@Html.LabelFor(model => model.ConfConfirmDate)</span>
                        @Html.TextBoxFor(model => model.ConfConfirmDate, new { @class = "table_inputs_SmallPadding2 inpputgr form-control VendConfCalendar VendorConfDetData" })
                    </div>
                </div>
                @*<div class=" col-lg-3">
                        <div class="input-group">
                            <span class="input-group-addon">@Html.LabelFor(model => model.ConfTourLeader)</span>
                            @Html.TextBoxFor(model => model.ConfTourLeader, new { @class = "form-control" })
                        </div>
                    </div>
                    <div class=" col-lg-3">
                        <div class="input-group">
                            <span class="input-group-addon">@Html.LabelFor(model => model.ConfEmployee)</span>
                            @Html.TextBoxFor(model => model.ConfEmployee, new { @class = "form-control" })
                            @Html.HiddenFor(model => model.ConfEmployeeId)
                        </div>
                    </div>*@
                <div class="ElementsPaddingRight30 col-lg-6" style="width:38.4% !important;">
                    <div class="input-group">
                        <span class="input-group-addon inpputgrtext table_inputs_SmallPadding2 inpputgrback">@Html.LabelFor(model => model.ConfNote)</span>
                        @Html.TextBoxFor(model => model.ConfNote, new { @class = "table_inputs_SmallPadding2 inpputgr form-control VendorConfDetData" })
                    </div>
                </div>
            </div>
            <div class="row form-row">
                <div class="ElementsPaddingRight30 col-lg-5" style="height: 24px;">
                    <div class="input-group">
                        <input type="file" id="UploadVendorConfirmFilePath" name="UploadVendorConfirmFilePath" style="width: 300px;margin-top: 2%;">
                        <input type="button" id="StartUpload" class="btn14 btn120" value="Upload File to Server" style="margin-left: 100%;margin-top: -8%;width: 150px;float: left;">
                    </div>
                </div>
                @if (Model.VendorConfirmFile != null)
                {
                    <div class="ElementsPaddingRight30 col-lg-7" id="DownloadDiv">
                        <div class="pull-left">
                            @Html.TextBoxFor(model => model.VendorConfirmFile, new { @style = "Display:None", @id = "VendorConfirmFileHidden" })
                            @Html.LabelForModel(Model.VendorConfirmFile.Split('/').Last())
                        </div>
                        <div class="input-group pull-right" style="margin-right:12px;">
                            <input type="button" class="btn14 btn120" id="Download" value="Download File">
                        </div>
                    </div>
                }
            </div>
            <div class="row form-row">
                <div class="ElementsPaddingRight30 col-lg-2" style="width:14% !important;">
                    <div class="input-group">
                        <span class="input-group-addon inpputgrtext table_inputs_SmallPadding2 inpputgrback">@Html.LabelFor(model => model.ConfRooms)</span>
                        @Html.TextBoxFor(model => model.ConfRooms, new { @class = "table_inputs_SmallPadding2 inpputgr form-control", @readonly = true })
                    </div>
                </div>
                <div class="ElementsPaddingRight30 col-lg-2" style="width:12% !important;">
                    <div class="input-group">
                        <span class="input-group-addon inpputgrtext table_inputs_SmallPadding2 inpputgrback">@Html.LabelFor(model => model.ConfPax)</span>
                        @Html.TextBoxFor(model => model.ConfPax, new { @class = "table_inputs_SmallPadding2 inpputgr form-control", @readonly = true })
                    </div>
                </div>
                <div class="ElementsPaddingRight30 col-lg-2">
                    <div class="input-group">
                        <span class="input-group-addon inpputgrtext table_inputs_SmallPadding2 inpputgrback">@Html.LabelFor(model => model.ConfLuggage)</span>
                        @Html.TextBoxFor(model => model.ConfLuggage, new { @class = "table_inputs_SmallPadding2 inpputgr form-control VendorConfDetData QuotaOnlyDecimalDigits" })
                    </div>
                </div>
                <div class="ElementsPaddingRight30 col-lg-2">
                    <div class="input-group">
                        <span class="input-group-addon inpputgrtext table_inputs_SmallPadding2 inpputgrback">@Html.LabelFor(model => model.ConfTax)</span>
                        @Html.TextBoxFor(model => model.ConfTax, new { @class = "table_inputs_SmallPadding2 inpputgr form-control VendorConfDetData QuotaOnlyDecimalDigits" })
                    </div>
                </div>
                <div class="ElementsPaddingRight30 col-lg-2">
                    <div class="input-group">
                        <span class="input-group-addon inpputgrtext table_inputs_SmallPadding2 inpputgrback">@Html.LabelFor(model => model.ConfOccTax)</span>
                        @Html.TextBoxFor(model => model.ConfOccTax, new { @class = "table_inputs_SmallPadding2 inpputgr form-control VendorConfDetData QuotaOnlyDecimalDigits" })
                    </div>
                </div>
                <div class=" col-lg-2 pull-right" style="width:15.4% !important;">
                    <input type="button" class="btn14 btn120" onclick="ReportVConfirmBreakDown()" value="BreakDown Preview">
                </div>
            </div>
                @*<div class="row form-row">

                @*<div class=" col-lg-2">
                    <div class="input-group">
                        <span class="input-group-addon">@Html.LabelFor(model => model.ConfGratuity)</span>
                        @Html.TextBoxFor(model => model.ConfGratuity, new { @class = "form-control" })
                    </div>
                </div>
            </div>*@

            </div>
    </div>
    <div style="display:none;">
        <div id="VCnfRoomDayDiv">
            <div class="OperationVcnfDay">
                <span>Day</span>
            </div>
        </div>
        <div id="VCnfSinglePriceDiv">
            <div class="OperationHotelRoomTypes">
                <span>S.$</span>
            </div>
        </div>
        <div id="VCnfSingleQtyDiv">
            <div class="OperationHandsontable">
                <span>Single</span>
            </div>
        </div>
        <div id="VCnfDoublePriceDiv">
            <div class="OperationHotelRoomTypes">
                <span>D.$</span>
            </div>
        </div>
        <div id="VCnfDoubleQtyDiv">
            <div class="OperationHandsontable">
                <span>Double</span>
            </div>
        </div>
        <div id="VCnfTwinPriceDiv">
            <div class="OperationHotelRoomTypes">
                <span>T.$</span>
            </div>
        </div>
        <div id="VCnfTwinQtyDiv">
            <div class="OperationHandsontable">
                <span>Twin</span>
            </div>
        </div>
        <div id="VCnfTriplePriceDiv">
            <div class="OperationHotelRoomTypes">
                <span>Tr.$</span>
            </div>
        </div>
        <div id="VCnfTripleQtyDiv">
            <div class="OperationHandsontable">
                <span>Triple</span>
            </div>
        </div>
        <div id="VCnfQuadPriceDiv">
            <div class="OperationHotelRoomTypes">
                <span>Q.$</span>
            </div>
        </div>
        <div id="VCnfQuadQtyDiv">
            <div class="OperationHandsontable">
                <span>Quad</span>
            </div>
        </div>
        <div id="VCnfDriverPriceDiv">
            <div class="OperationHotelRoomTypes">
                <span>Dr.$</span>
            </div>
        </div>
        <div id="VCnfDriverQtyDiv">
            <div class="OperationHandsontable">
                <span>Driver</span>
            </div>
        </div>
        <div id="VCnfGuidePriceDiv">
            <div class="OperationHotelRoomTypes">
                <span>G.$</span>
            </div>
        </div>
        <div id="VCnfGuideQtyDiv">
            <div class="OperationHandsontable">
                <span>Guide</span>
            </div>
        </div>
        <div id="VCnfBaggagePriceDiv">
            <div class="OperationHotelRoomTypes">
                <span>Bag.$</span>
            </div>
        </div>
        <div id="VCnfBaggageQtyDiv">
            <div class="OperationHandsontable">
                <span>Baggage</span>
            </div>
        </div>
        <div id="VCnfABFPriceDiv">
            <div class="OperationHotelRoomTypes">
                <span>ABF.$</span>
            </div>
        </div>
        <div id="VCnfABFQtyDiv">
            <div class="OperationHandsontable">
                <span>ABF</span>
            </div>
        </div>
        <div id="VCnfCBFPriceDiv">
            <div class="OperationHotelRoomTypes">
                <span>CBF.$</span>
            </div>
        </div>
        <div id="VCnfCBFQtyDiv">
            <div class="OperationHandsontable">
                <span>CBF</span>
            </div>
        </div>
        <div id="VCnfLunchPriceDiv">
            <div class="OperationHotelRoomTypes">
                <span>Lunch.$</span>
            </div>
        </div>
        <div id="VCnfLunchQtyDiv">
            <div class="OperationHandsontable">
                <span>Lunch</span>
            </div>
        </div>
        <div id="VCnfDinnerPriceDiv">
            <div class="OperationHotelRoomTypes">
                <span>Dinner.$</span>
            </div>
        </div>
        <div id="VCnfDinnerQtyDiv">
            <div class="OperationHandsontable">
                <span>Dinner</span>
            </div>
        </div>
        <div id="VCnfDateDiv">
            <div class="OperationHandsontable">
                <span>Date</span>
            </div>
        </div>
    </div>
    <div id="OperVConfirmRoomGrid" class="handsontable" style="width: 1172px; height: 130px; overflow: auto; display: none;"> </div>
    <div style="padding-top:5px;">
    <div id="OperVConfirmMealGrid" class="handsontable" style="width: 850px; height: 130px; overflow: auto; display: none; "> </div>
        <div><button class="btn14 btn120 pull-right" onclick="UpdateProvide()" type="button">Update Provide</button></div>
    </div>
        <div style="padding-top:5px">
        <div class="OperationTabsTitleDiv">
            <span class="OperationTabsTitle">Extra</span>
        </div>
        <div id="OperVConfirmGrid" class="handsontable" style="width: 1172px; height: 120px; overflow-y: auto; display: none; "> </div>
    </div>
    <div style="padding-top:10px;float:right">
        <button class="btn14 btn60 pull-right" id="operVendConfsavebtn" onclick="VConfirmGridSave()" type="button">Save</button>
        @*<input type="button" id="GroupVendorRoomingReportBtn" class="btn14 btn60" value="Preview">*@
    </div>

}





